<?php
/**
 * 设置api异常类
 * User: sunlight
 * Date: 2018/11/21
 * Time: 17:16
 */

namespace app\common\lib\exception;

use think\Exception;
use think\exception\Handle;

class ApiHandleException extends Handle{

    /**
     * http 状态码
     * @var int
     */
    public $httpCode = 500;

    public function renfer(Exception $e){
        if (config('app_debug')==true){
            return parent::render($e);
        }
        if ($e instanceof ApiException){
            $this->httpCode=$e->httpCode;
        }
        return show(0,$e->getMessage(),[] ,$this->httpCode);
    }

}